package com.zb.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zb.Service.RoomkindService;
import com.zb.entity.Roomkind;

@Scope("prototype")
@Component
@RequestMapping("/roomKind")
public class RoomKindController {
	@Resource
	private RoomkindService rs;
	@RequestMapping(params="op=show")
	@ResponseBody
	public List<Roomkind> toshow(){
		List<Roomkind> rlist = rs.findRoomkindAll();
		return rlist;
	}
	
	@RequestMapping(params="op=save")
	public String tosave(String name,String descroom){
		Roomkind r = new Roomkind();
		r.setName(name);
		r.setDescroom(descroom);
		rs.saveRoomKind(r);
		return "room";
	}
	
	@RequestMapping(params="op=delete")
	public String todelete(int id){
		rs.delectRoomKind(id);
		return "room";
	}
	@RequestMapping(params="op=showOk")
	@ResponseBody
	public List<Roomkind> toshowOk(String start,String end){
		List<Roomkind> rlist = rs.findRoomKind(start, end);
		return rlist;
	}

}
